<?php
   $id=$_GET['id'];
   $connect=mysql_connect("localhost","root","192510");
   mysql_select_db("news",$connect);
   $sql="select * from user where id=$id";
   $result=mysql_query($sql);
   $row=mysql_fetch_array($result); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.6.3.min.js"></script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">用户管理</a></li>
	<?php
	if($id==null){
	?>
	<li><a href="#">添加用户</a></li>
	<?php
	}else{
	?>	
	<li><a href="#">编辑用户</a></li>
	<?php	
	}
	?>
    </ul>
    </div>
    
    <div class="formbody">
    
    <div class="formtitle"><span>基本信息</span></div>
    <form method="post" action="insert_user_commit.php">
    <ul class="forminfo">
    <li><label>用户名</label><input name="username" id="username" type="text" onblur="user();" class="dfinput" value="<?php echo $row['username'];?>" /><i style="display:none;" id="yz_user">用户名不能为空</i></li>
    <li><label>密码</label><input name="password" id="password" type="password" class="dfinput" onblur="pass();" value="<?php echo $row['password'];?>"/><i style="display:none;" id="yz_pass">密码不能为空</i>
    <li><label>用户状态</label><select  name="status" id="status">
								<option value="1"  <?php echo (isset($row)&&$row['status']==0)?'selected=selected':'';?>>普通用户</option>
								<option value="0"  <?php echo (isset($row)&&$row['status']==1)?'selected=selected':'';?>>管理员</option>
								<option value="2"  <?php echo (isset($row)&&$row['status']==2)?'selected=selected':'';?>>录入员</option>
								</select></li>
    <li><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认保存" onclick="return tijiao();"/></li>
    </ul>
	</form>
	
    </div>
</body>
</html>
<script>
	 function user(){
		 //根据特殊条件做出特殊的处理
		var username=$("#username").val();
		if(username==null||username.length==0){
			$("#yz_user").show();
			
		}else{
			$("#yz_user").hide();
		}
	 }
	 
	  
	 function pass(){
		 var password=$("#password").val();
		 if(password==null||password.length==0){
			 $("#yz_pass").show();
		 }else{
			 $("#yz_pass").hide();
		 }
	 }

	 
	  function tijiao(){
		  var username=$("#username").val();
		  var password=$("#password").val();
		  
		  if(username==null||username.length==0||password==null||password.length==0){
			  alert("用户名或密码不能为空");
			  return false;
			 
		  }else{
			   return true;
		  }
		 
	  }
	  
</script>

